using UnityEngine;
using UnityEngine.UI;

namespace Voodoo.Meta.RVModules
{
	public class KeyVisual : MonoBehaviour
	{
		public Image image;

		public Sprite keyEnable;

		public Sprite keyDisable;

		public Color disableColor;

		public Image fadeLight;

		public bool isKeyEnable;

		public bool CanBeEnable()
		{
			if (!isKeyEnable)
			{
				Enable();
				return true;
			}
			return false;
		}

		public void Enable()
		{
			CheckImage();
			image.sprite = keyEnable;
			image.color = Color.white;
			isKeyEnable = true;
			fadeLight.enabled = true;
		}

		public bool CanBeDisable()
		{
			if (isKeyEnable)
			{
				Disable();
				return true;
			}
			return false;
		}

		public void Disable()
		{
			CheckImage();
			image.sprite = keyDisable;
			image.color = disableColor;
			isKeyEnable = false;
			fadeLight.enabled = false;
		}

		private void CheckImage()
		{
			if (image == null)
			{
				image = GetComponent<Image>();
			}
		}

		public void Dispose()
		{
			image = null;
			keyEnable = null;
			keyDisable = null;
			fadeLight = null;
		}
	}
}
